home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC_Samples / propdlg / shapedoc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  2.8 KB  |  135 lines

  1. // shapedoc.cpp : implementation of the CShapesDoc class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1999 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "propdlg.h"
  15.  
  16. #include "shapeobj.h"
  17. #include "colorpge.h"
  18. #include "stylepge.h"
  19. #include "propsht.h"
  20. #include "propsht2.h"
  21. #include "shapedoc.h"
  22. #include "shapesvw.h"
  23.  
  24. #include "mainfrm.h"
  25.  
  26.  
  27. #ifdef _DEBUG
  28. #undef THIS_FILE
  29. static char BASED_CODE THIS_FILE[] = __FILE__;
  30. #endif
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CShapesDoc
  34.  
  35. IMPLEMENT_DYNCREATE(CShapesDoc, CDocument)
  36.  
  37. BEGIN_MESSAGE_MAP(CShapesDoc, CDocument)
  38.     //{{AFX_MSG_MAP(CShapesDoc)
  39.     //}}AFX_MSG_MAP
  40. END_MESSAGE_MAP()
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CShapesDoc construction/destruction
  44.  
  45. CShapesDoc::CShapesDoc()
  46. {
  47. }
  48.  
  49. CShapesDoc::~CShapesDoc()
  50. {
  51.     POSITION pos = m_shapeList.GetHeadPosition();
  52.     while (pos != NULL)
  53.     {
  54.         delete m_shapeList.GetNext(pos);
  55.     }
  56. }
  57.  
  58. BOOL CShapesDoc::OnNewDocument()
  59. {
  60.     if (!CDocument::OnNewDocument())
  61.         return FALSE;
  62.  
  63.     m_shapeList.RemoveAll();
  64.  
  65.     CShape* pShapeNew = new CShape(
  66.         black,
  67.         rectangle,
  68.         CRect(20,20,120,120));
  69.  
  70.     AddShape(pShapeNew);
  71.  
  72.     CShapesView* pView;
  73.     POSITION pos = GetFirstViewPosition();
  74.     if(pos != NULL)
  75.     {
  76.         pView = (CShapesView*)GetNextView(pos);
  77.         pView->m_pShapeSelected = NULL;
  78.     }
  79.  
  80.     return TRUE;
  81. }
  82.  
  83. /////////////////////////////////////////////////////////////////////////////
  84. // CShapesDoc operations
  85.  
  86. void CShapesDoc::AddShape(CShape* pShapeNew)
  87. {
  88.     m_shapeList.AddHead(pShapeNew);
  89.     UpdateAllViews(NULL);
  90. }
  91.  
  92. CShape* CShapesDoc::HitTest(CPoint pt)
  93. {
  94.     CShape* pShapeHit;
  95.     POSITION pos = m_shapeList.GetHeadPosition();
  96.     while (pos != NULL)
  97.     {
  98.         pShapeHit = m_shapeList.GetNext(pos);
  99.         if (pShapeHit->m_rect.PtInRect(pt))
  100.             return pShapeHit;
  101.     }
  102.     return NULL;
  103. }
  104.  
  105. /////////////////////////////////////////////////////////////////////////////
  106. // CShapesDoc serialization
  107.  
  108. void CShapesDoc::Serialize(CArchive& ar)
  109. {
  110.     m_shapeList.Serialize(ar);
  111. }
  112.  
  113. /////////////////////////////////////////////////////////////////////////////
  114. // CShapesDoc diagnostics
  115.  
  116. #ifdef _DEBUG
  117. void CShapesDoc::AssertValid() const
  118. {
  119.     CDocument::AssertValid();
  120. }
  121.  
  122. void CShapesDoc::Dump(CDumpContext& dc) const
  123. {
  124.     CDocument::Dump(dc);
  125. }
  126. #endif //_DEBUG
  127.  
  128. /////////////////////////////////////////////////////////////////////////////
  129. // CShapesDoc commands
  130.  
  131. BOOL CShapesDoc::SaveModified() 
  132. {
  133.     return TRUE;
  134. }
  135.